
<style type="text/css">
.sidebarTop {
	position: fixed;	  
	 top:5%;
	 right: 15%; 
}

.sidebarDefault {
	position: relative;
}
</style>

<script type="text/javascript">

$(function(){
	 var sidebar = $('#myScrollspy');
	 
		pos = sidebar.offset();	 
		$(window).scroll(function(){
					
			if($(this).scrollTop() > pos.top+sidebar.height() && sidebar.hasClass('sidebarDefault')){								
				sidebar.fadeOut('fast', function(){
					$(this).removeClass('sidebarDefault').addClass('sidebarTop').fadeIn('fast');
				});
			} else if($(this).scrollTop() <= pos.top && sidebar.hasClass('sidebarTop')){
				sidebar.fadeOut('fast', function(){
					$(this).removeClass('sidebarTop').addClass('sidebarDefault').fadeIn('fast');
				});
			}
		}); 

});

</script>

<?php

$sidebarList = $this->requestAction('posts/getSidebarList');

?>



<div id="myScrollspy" class="sidebarDefault col-md-offset-1" >
	<h2 class="star">
		<span>Posted In Months</span> 
	</h2>
	<div class="clr"></div>
	<ul class="sb_menu">
          	<?php foreach ($sidebarList as $result):?>
            <li><a
			href="/posts/listByMonth/<?php echo $result[0]['month_year'];?>">
            <?php
												echo date ( 'F o', strtotime ( $result [0] ['month_year'] . '-1' ) );
												?>
            </a></li>
            <?php endforeach;?>            
          </ul>
</div>


